/********************************************************************
Name: Figure A1: Detainer Requests Sent to Sheriffs Over Time
Author: Dan Thompson
Date: August 2019
Notes:
********************************************************************/

* Set the working directory 
gl root = "$sanctuary_root"
gl root = "YOUR_WORKING_DIRECTORY"

* Get the number of detainer requests over time
use "$root/data/panel of outcomes.dta", clear
collapse (sum) all_sheriff detained_sheriff ///
	(sum) all_not_sheriff detained_not_sheriff ///
	(sum) all_crime0 detained_crime0 ///
	(sum) all_crime1 detained_crime1 ///
	(sum) all_crime2 detained_crime2 ///
	(sum) all_crime3 detained_crime3, ///
	by(policy_year)
foreach v of varlist * {
	if "`v'"!="policy_year" replace `v' = `v'/1000
}
gen share_detained_sheriff = detained_sheriff/all_sheriff

* Run the plot
twoway (bar all_sheriff policy_year, barwidth(0.8)) ///
	(bar detained_sheriff policy_year, barwidth(0.8)) ///
	(connected share_detained_sheriff policy_year, yaxis(2) lc(gs3) mc(gs3)), ///
	legend(order(1 "Requests" 2 "Detained" 3 "Compliance Rate") cols(3)) ///
	xsc(r(2006 2016)) xlab(2006(2)2016) xti("Year") ///
	ysc(r(0 1) axis(2)) ylab(0(.25)1, axis(2)) ///
	yti("Number of Immigrants (1,000s)", axis(1)) yti("Compliance Rate", axis(2)) ///
	bgcolor(white) graphregion(color(white)) ///
	name("compliance_rate", replace)
